/*
 * @author: lican02
 * @description:根据函数后缀名查找文件
 */

function findFileByExc(staticPath, exc, result = []) {
  const dirs = fs.readdirSync(staticPath)
  dirs.map(path_ => path.join(staticPath, path_)).forEach(absolutePath => {
    const stats = fs.statSync(absolutePath)
    if (stats.isDirectory()) {
      findFileByExc(absolutePath, exc, result)
    } else {
      if (stats.isFile() && exc === path.extname(absolutePath)) {
        result.push(absolutePath)
      }
    }
  })
  return result
}

module.exports = {
  findFileByExc
}